package net.myspring.common.config;

import net.myspring.common.service.ServiceException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by admin on 2016/9/8.
 */
@ControllerAdvice
public class ExceptionHandlerController {

    @ExceptionHandler(value = ServiceException.class)
    public ModelAndView defaultErrorHandler(HttpServletRequest req, Exception e) throws Exception {
        ModelAndView mav = new ModelAndView();
        mav.addObject("exception", e.getMessage());
        mav.setViewName("/sys/accessDenied");
        return mav;
    }

}
